import axios from '../../axios.js';
import { date_range, formatDate, city, currentPage, pageSize, tableData, total, netData } from './ex_list.vue.js';

export const getEx = async () => {
if (date_range.value !== "") {
const s = formatDate(date_range.value[0]);
const e = formatDate(date_range.value[1]);
}
const { data: res } = await axios.get(`ex/page`, {
params: {
city: city.value,
date_range: [].join(","),
pageNum: currentPage.value,
pageSize: pageSize.value
}
});
tableData.value = [];
// 假设你已经创建了名为 tableData 的 ref 对象
res.data.records.forEach(ele => {
tableData.value.push({
id: ele.idZzxcsm,
categoryId: ele.categoryIdZzxcsm,
title: ele.titleZzxcsm,
stime: ele.stimeZzxcsm,
etime: ele.etimeZzxcsm,
city: ele.cityZzxcsm,
address: ele.addressZzxcsm,
host: ele.hostZzxcsm,
price: ele.priceZzxcsm,
detail: ele.detailZzxcsm.split(','),
content: ele.contentZzxcsm,
status: ele.statusZzxcsm === 1 ? true : false,
cosers: ele.cosersZzxcsm.map(coser => ({
id: coser.idZzxcsm,
exId: coser.exIdZzxcsm,
name: coser.nameZzxcsm,
imgurl: coser.imgurlZzxcsm,
content: coser.contentZzxcsm
}))
});
});
total.value = res.data.total;
netData.value = tableData.value;
};
